// FunctionObject.h: interface for the FunctionObject class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FUNCTIONOBJECT_H__0EC5B958_8A66_4752_BC6C_F33049766C28__INCLUDED_)
#define AFX_FUNCTIONOBJECT_H__0EC5B958_8A66_4752_BC6C_F33049766C28__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "FunctionRegisterInfo.h"
#include "RegisterObject.h"

class Part;
class FunctionVisitor;
class ModelObject;

class AFX_EXT_CLASS FunctionObject :public RegisterObject<FunctionObject, FunctionRegisterInfo> 
{
	DECLARE_DYNAMIC_EX(FunctionObject)
protected:
	FunctionObject();

public:
	enum{
		eJOINTCHOOSE = 888,
		eJONTATTACHMATRIX = 889,
		eJOINTMATCHFUNCTION = 990,
		eINITFUNCTION = 991,
		eGETPROPERTYFUNCTION = 992,
		eJOINTFUNCTION = 993,
		eMAXLOAD = 994,
		eSELCONSTSPRING = 995,
		eSELSPRING = 996,
		eFORCEASSIGN = 997,
		eBHCONSTRUCT = 998,
		eSADISASSEMBLY = 1000
	};

public:
	virtual ~FunctionObject();

public:
	virtual BOOL Execute() {return TRUE;}
	virtual void RegisterToSupport(){}
	virtual void RegisterToString(){}
	virtual void UnRegisterToSupport(){}
	virtual void UnRegisterToString(){}
	virtual BOOL Accept(FunctionVisitor* pVisitor){ASSERT(FALSE);return TRUE;}
	virtual FunctionObject* Clone(){ASSERT(FALSE);return NULL;}

	ModelObject* GetOwner(){
		return m_pPart;
	}

	virtual void SetOwner(ModelObject* pPart){
		ASSERT(pPart);
		m_pPart = pPart;
	}

	INT GetFunctionStyle(){
		return this->GetRegisterInfo()->GetKey();
	}

private:
	ModelObject* m_pPart;
	
protected:
	void RegisterToModel(ModelObject& object);
	void UnRegisterToModel(ModelObject& object);

	FunctionObject* NextRegister(){
		return m_pNextRegister;
	}

	void NextRegister(FunctionObject* pNext){
		ASSERT(pNext);
		m_pNextRegister = pNext;
	}
	
	INT GetRegisterFunctionNum();
protected:
	FunctionObject* m_pNextRegister;
};

#endif // !defined(AFX_FUNCTIONOBJECT_H__0EC5B958_8A66_4752_BC6C_F33049766C28__INCLUDED_)
